| API Documentation |  |

- MAIN PAGE
- NAMESPACES
- CLASSES

Public Member Functions | List of all members
nkInputs::MouseDeviceManager Class Referencefinal

Manages the mouse devices available in the component. More...

Inheritance diagram for nkInputs::MouseDeviceManager:

## Public Member Functions
System * | getSystem () const
MouseDevice * | createOrRetrieve (nkMemory::StringView name)
MouseDevice * | record (nkMemory::StringView name, nkMemory::UniquePtr< MouseDevice > device)
MouseDevice * | get (nkMemory::StringView name) const
MouseDevice * | getByIndex (unsigned int index) const
void | rename (nkMemory::StringView currentName, nkMemory::StringView newName)
void | erase (nkMemory::StringView name)
nkMemory::UniquePtr< MouseDevice > | relinquish (nkMemory::StringView name)

## Detailed Description

Manages the mouse devices available in the component.

At all times, managers own any memory allocated inside, through the creation methods, or ownership given to them. External code should never delete memory returned by it, unless the ownership is passed back through the dedicated method.

## Member Function Documentation

## ◆ getSystem()

System* nkInputs::MouseDeviceManager::getSystem | ( |  | ) | const

Returns
  The System in which the manager works.

## ◆ createOrRetrieve()

MouseDevice* nkInputs::MouseDeviceManager::createOrRetrieve | ( | nkMemory::StringView | name | ) |

Creates if unavailable, or retrieves if available, a mouse device.

Parameters

  name | The name of the device to retrieve.

Returns
  The device requested, possibly freshly created. The manager owns the memory returned, external code should never delete it. See erase().

## ◆ record()

MouseDevice* nkInputs::MouseDeviceManager::record | ( | nkMemory::StringView | name,
|  | nkMemory::UniquePtr< MouseDevice > | device
| ) |  |

Records an already existing resource, passing its ownership to the manager. This method can be used after manually creating a resource, as needed, as long as the resource provided is part of the same System.

Parameters

  name | The name to register the resource to.
  device | The device to register.

Returns
  The raw pointer over the registered device.

Remarks
  The device provided needs to be living inside the same System as the Manager does. Doing so will fail the recording, log a warning and erase the device right away, as the ownership is passed during calling.

## ◆ get()

MouseDevice* nkInputs::MouseDeviceManager::get | ( | nkMemory::StringView | name | ) | const

Retrieves a mouse device.

Parameters

  name | The name of the device to retrieve.

Returns
  The device requested if available, nullptr else.

## ◆ getByIndex()

MouseDevice* nkInputs::MouseDeviceManager::getByIndex | ( | unsigned int | index | ) | const

Retrieves a device by index. Keep in mind that as devices are added / erased, the same index can return a different device. This function is useful when retrieving all existing devices in one go.

Parameters

  index | The index from which to retrieve a device.

Returns
  The device currently attached to the index if available, nullptr else.

## ◆ rename()

void nkInputs::MouseDeviceManager::rename | ( | nkMemory::StringView | currentName,
|  | nkMemory::StringView | newName
| ) |  |

Renames a mouse device.

Parameters

  currentName | The name of the device to rename.
  newName | The name to reassign to the device.

## ◆ erase()

void nkInputs::MouseDeviceManager::erase | ( | nkMemory::StringView | name | ) |

Erases and frees a mouse device.

Parameters

  name | The name of the device to erase.

## ◆ relinquish()

nkMemory::UniquePtr<MouseDevice> nkInputs::MouseDeviceManager::relinquish | ( | nkMemory::StringView | name | ) |

Relinquishes a device's ownership, leaving its lifetime management to the caller.

Parameters

  name | The name of the device to return back.

Returns
  The device requested.

The documentation for this class was generated from the following file:

- Documentation/Headers/NilkinsInputs/Devices/Mouses/MouseDeviceManager.h